package cz.fit.dpo.task1;

/**
 * class for representing the player of this game
 */
public class Player extends Person {

	/**
	 * maximum number of items player can carry
	 */
	public static final int MAX_LOAD = 5;
	
	/**
	 * can player moves to specific room?
	 */
	public boolean canMove (Room toBeNewRoom) {
		return !isHeavy();
	} 
	
	/**
	 * can player drop specific item?
	 */
	public boolean canDrop (Item toBeDroppedItem) {
		return true;
	} 
	
	/**
	 * can player lift specific item?
	 */
	public boolean canLift (Item toBeLiftedItem) {
		return !isHeavy();
	} 

	/**
	 * lifts an item
	 */
	public void lift (Item newItem) {
		addOwnedItem(newItem);
		newItem.setOwner(this);
	}
	
	/**
	 * does player own an item?
	 */
	public boolean owns (Item item) {
		return ownedItems.contains(item);
	}

	/**
	 * is player too heavy to walk/lift an item etc.?
	 */
	private boolean isHeavy () {
		if (ownedItems.size()>=MAX_LOAD)  {
			return true;
		}
		return false;
	}
	
	/**
	 * moves player to another room
	 */
	public void moveToRoom ( Room newRoom ) {
		inRoom = newRoom;
		addVisitedRoom(newRoom);
	}
	
	/**
	 * drop an item
	 */
	public void drop ( Item lostItem ) {
		removeOwnedItem ( lostItem );
	}
	
	/**
	 * remove item from player's bag
	 */
	public void removeOwnedItem ( Item lostItem ) {
		ownedItems.remove (lostItem);
	}
}
